﻿using System.Collections.Generic;
using System.ServiceModel.Description;
using System.Xml;
using System.Xml.Schema;
using MockingBird.Xml.XIG;
using Thinktecture.Tools.Wscf.Services.ServiceDescription.Contract;

namespace MockingBird.Studio.UI.Helpers
{
    internal static class MessageHelper
    {
        internal static XmlDocument GenerateInstance(MessageDescription message, XmlSchemaSet schemaSet)
        {
            XmlQualifiedName qName = ServiceDefinition.GetMessageQName(message);
            IXmlInstanceGenerator xig = new SimpleXmlInstanceGenerator();
            return xig.GenerateInstance(schemaSet, qName);
        }

        internal static List<XmlDocument> GenerateInstances(List<MessageDescription> messages, XmlSchemaSet schemaSet)
        {
            List<XmlDocument> instanceDocs = new List<XmlDocument>();

            foreach (MessageDescription md in messages)
            {
                instanceDocs.Add(GenerateInstance(md, schemaSet));

            }

            return instanceDocs;
        }
    }
}
